package com.fzf.org.controller;

import com.fzf.org.enums.AuditEnums;
import com.fzf.org.result.Result;
import com.fzf.org.result.Results;
import com.fzf.org.service.BlogAuditService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * 博客审核控制器
 * 无法正常使用
 */
@Slf4j
@RestController
@RequestMapping("/blog/audit")
@RequiredArgsConstructor
public class BlogAuditController {

    private final BlogAuditService blogAuditService;

    /**
     * 手动提交博客审核请求
     *
     * @param blogId 博客ID
     * @return 处理结果
     */
    @PostMapping("/{blogId}")
    public Result<Boolean> auditBlog(
            @PathVariable Long blogId) {
        
        log.info("Received audit request for blogId: {}", blogId);
        // 调用服务发送审核请求
        return Results.success(blogAuditService.sendBlogAuditRequest(blogId));
    }

    /**
     * 模拟审核接口 - 总是返回审核不通过
     * 
     * @param request 审核请求
     * @return 审核结果
     */
    @PostMapping("/mock-review")
    public ResponseEntity<Map<String, Object>> mockReview(@RequestBody Map<String, Object> request) {
        log.info("Received mock review request: {}", request);
        
        // 构造审核不通过的响应
        Map<String, Object> response = new HashMap<>();
        response.put("success", false);
        response.put("message", "审核不通过");
        
        Map<String, Object> data = new HashMap<>();
        data.put("status", AuditEnums.REJECTED.getValue());
        data.put("reason", "模拟审核：内容不符合平台规范");
        response.put("data", data);
        
        log.info("Mock review result: {}", response);
        return ResponseEntity.ok(response);
    }

}